package com.longge;

public class DominantIndex {

    public int dominantIndex(int[] nums) {

        int max = Integer.MIN_VALUE;
        int index = 0;
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            if (max < num) {
                max = num;
                index = i;
            }


        }
        for (int num : nums) {
            if (max != num && max / 2 < num) {
                return -1;
            }
        }
        return index;
    }
}
